package com.example.templateapp.ui.bottom

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.alibaba.android.vlayout.layout.GridLayoutHelper
import com.example.templateapp.R
import com.example.templateapp.ui.adapter.base.SimpleDelegateAdapter
import com.example.templateapp.widget.BottomSheetListDialog
import com.google.android.material.bottomsheet.BottomSheetDialog
import com.xuexiang.xui.adapter.recyclerview.RecyclerViewHolder
import kotlinx.android.synthetic.main.activity_bottom_dialog.*

class BottomDialogActivity : AppCompatActivity() {

    companion object {
        val array = arrayOf(
            R.mipmap.avatar1,
            R.mipmap.avatar2,
            R.mipmap.avatar3,
            R.mipmap.avatar4,
            R.mipmap.avatar5,
            R.mipmap.avatar6,
            R.mipmap.avatar7,
            R.mipmap.avatar8,
            R.mipmap.avatar9,
            R.mipmap.avatar10,
            R.mipmap.avatar11,
            R.mipmap.avatar12,
            R.mipmap.avatar13,
            R.mipmap.avatar14,
            R.mipmap.avatar15,
            R.mipmap.avatar16,
            R.mipmap.avatar17,
            R.mipmap.avatar18,
            R.mipmap.avatar19,
            R.mipmap.avatar20,
            R.mipmap.avatar21,
            R.mipmap.avatar22,
            R.mipmap.avatar23,
            R.mipmap.avatar24,
            R.mipmap.avatar25,
            R.mipmap.avatar26,
            R.mipmap.avatar27,
            R.mipmap.avatar28,
            R.mipmap.avatar29,
            R.mipmap.avatar30,
            R.mipmap.avatar31,
            R.mipmap.avatar32,
            R.mipmap.avatar33,
            R.mipmap.avatar34,
            R.mipmap.avatar35,
            R.mipmap.avatar36,
            R.mipmap.avatar37,
            R.mipmap.avatar38,
            R.mipmap.avatar39,
            R.mipmap.avatar40,
            R.mipmap.avatar41,
            R.mipmap.avatar42,
            R.mipmap.avatar43,
            R.mipmap.avatar44,
            R.mipmap.avatar45,
            R.mipmap.avatar46
        )
    }


    private val bottomDialog: BottomSheetDialog by lazy {
        BottomSheetListDialog.getDialog(
            this, "选择头像",
            object : SimpleDelegateAdapter<Int>(
                R.layout.adapter_avatar_item, GridLayoutHelper(4), array

            ) {
                override fun bindData(holder: RecyclerViewHolder, position: Int, item: Int) {
                    holder.image(R.id.avatar, item)
                    holder.itemView.setOnClickListener {
                        imageView3.setImageResource(array[position])
                        bottomDialog.dismiss()
                    }
                }

            }, true
        )


/*        BottomSheetMultiSelectDialog.getDialog(this, arrayOf(
            "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
        ), listener = object : BottomSheetMultiSelectDialog.OnConfirmListener {
            override fun onConfirm(selectIdxs: MutableSet<Int>) {

            }
        })*/
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_bottom_dialog)

        button2.setOnClickListener {

            bottomDialog.show()
        }
    }
}